package baselib

import (
	"net/http"
)

/**
 * 多路转接向所有客户端更新状态
 */
 func MonoBranch() {
	for {
		select {
		case pack := <-MessChannel:
			ghash := MonoGroup[pack["gid"]]
			for so := range ghash {
				// 并行发送
				go func(so MonoClient, pack map[string]string) {
					so <- pack
				}(so, pack)
			}
		// end case
		case client := <-BindChannel:
			ghash := MonoGroup[client.gid]
			ghash[client.channel] = true
		// end case
		case client := <-LeaveChannel:
			ghash := MonoGroup[client.gid]
			delete(ghash, client.channel)
			close(client.channel)
		// end case
		}
	}
}